<? if (!defined("BASEPATH")) exit("No direct script access allowed");

echo	"<h2>".$title."</h2>";

$getSearchListCount = 0;
if(isset($getSearchList["cnt"])) {
	$getSearchListCount = $getSearchList["cnt"];
	unset($getSearchList["cnt"]);
}

if(count($getSearchList)) {
	echo	"<h3><p class=\"fl\">".$this->lang->line("NUMBER_OF_RESULTS").": ".$getSearchListCount."</fl><p class=\"fr\">[".($start+1)." - ".min($getSearchListCount, $start+$this->config->item("searchPageSize"))."]<p><br class=\"cb\" /></h3>";
} else {
	echo	"<div class=\"alert_error\">".$this->lang->line("NO_RESULTS_FOUND_TRY_ANOTHER_SEARCH")."</div>";
}

$jj = $start + 1;
foreach($getSearchList as $type => $typeData) {
	foreach($typeData as $ent) {
		echo	"<div class=\"box ".(($jj%2)?("gray"):(""))."\">";
		echo		"<h3>".anchor($ent["url"], $ent["name"])." <p class=\"searchresult color".(($jj%2)?("white"):("gray"))." fr\">".$jj.".</p></h3><br class=\"cb\" />";
		switch($type) {
			case "CITY": {
				echo		"<p class=\"fl\">".anchor($ent["conUrlName"]."/".$ent["couUrlName"], $ent["couName"])."</p>";
				echo		"<br class=\"cb\" />";
			} break;
			case "INS": {
				echo		"<p class=\"fl\">".anchor($ent["conUrlName"]."/".$ent["couUrlName"]."/".$ent["cityUrlName"], $ent["cityName"])." (".anchor($ent["conUrlName"]."/".$ent["couUrlName"], $ent["couName"]).")</p>";
				echo		"<br class=\"cb\" />";
			} break;
			case "MAJ": {
				echo		"<p class=\"fl\">".anchor("institutes/".$ent["insUrlName"], $ent["insName"])."</p>";
				echo		"<p class=\"fr\">".anchor($ent["conUrlName"]."/".$ent["couUrlName"]."/".$ent["cityUrlName"], $ent["cityName"])." (".anchor($ent["conUrlName"]."/".$ent["couUrlName"], $ent["couName"]).")</p>";
				echo		"<br class=\"cb\" />";
			} break;
		}
		if($ent["description"]) {
			echo		"<br class=\"cb\" />";
			echo		auto_link($ent["description"]);
			echo		"<br class=\"cb\" />";
		}
		echo		"<p class=\"fr\">".anchor($ent["url"], $this->lang->line("VIEW_DETAIL"))."</p>";
		echo		"<br class=\"cb\" />";
		echo	"</div>";
		$jj++;
	}
}

$config["base_url"] = base_url()."search";
$config["total_rows"] = $getSearchListCount;
$config["uri_segment"] = 2;
$config["num_links"] = 10;
$config["per_page"] = $this->config->item("searchPageSize");

$this->pagination->initialize($config);

echo	"<div class=\"fr\">";
echo		$this->pagination->create_links();
echo	"</div>";
echo	"<br class=\"cb\" />";

return;
echo	"<ul>";
foreach($getSearchList as $ENTITY => $entData) {
	foreach($entData as $entId => $data) {
		echo		"<li>".anchor($data["url"], $data["name"])."</li>";
	}
}
echo	"</ul>";

?>
<script type="text/javascript">

	$(document).ready(function() {
		$('#mainmenu').mouseover();
		$('.search-result-box').each(function(){
			if($(this).height() > 200) {
				$(this).height(200);
			}
		});

	});

</script>
<?

$ii = 0;
foreach($getSearchList as $ENTITY => $entData) {
	foreach($entData as $entId => $data) {
		echo	"<div style=\"overflow: hidden; text-overflow:ellipsis;\" class=\"search-result-box f".(($ii%2)?("l"):("l"))."\">";
		echo		"<h3>".anchor($data["url"], $data["name"])."</h3>";
		if(isset($data["cat"])) {
			echo		"<dl>";
			foreach($data["cat"] as $catData) {
				if($catData["catName"]) {
					echo		"<dt class=\"b fl\">".$catData["catName"].":&nbsp;</dt>";
				}
				echo		"<dd>".Common::coalesce(array(Common::numericFormat($catData["e2cInt"]), auto_link($catData["e2cText"], "both", TRUE)))."</dd>";
			}
			echo		"</dl>";
		}
		echo	"</div>";
		$ii++;
	}
}

//Common::pr($getSearchList);